package com.qk.mapper;

import com.qk.entity.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RoleMapper {
    //4. 根据ID查询
    @Select("select id, name, label, remark, create_time, update_time from role where id = #{id}")
     Role selectById(Integer id);
    //2. 删除角色
    @Delete("delete from role where id = #{id}")
     void deleteById(Integer id) ;
    //1. 角色列表查询
    List<Role> selectList(String name, String label) ;
    //3. 添加角色
    @Insert("insert into role( name, label, remark, create_time, update_time) values(#{name},#{label},#{remark},#{createTime},#{updateTime})")
    public void insert(Role role);
    //5. 修改角色
    void update(Role role);
    //6. 查询所有角色
    @Select("SELECT id, name, label, remark, create_time, update_time FROM role ORDER BY update_time DESC")
    List<Role> getAllRoles();
}
